<template>
  <div>
    home
    {{message}}
    {{mes}}
    <el-button @click="addCourseCategory">添加</el-button>
    <el-button @click="deleteCourseCategory">删除</el-button>
  </div>
</template>

<script>
import { getAdminList, getCourse, addCourseCategory, deleteCourseCategory, getCourseCategory } from '@/api/account.js'
import { mapState } from 'vuex'
export default {
  data () {
    return {
      message: '123'
    }
  },
  computed: {
    ...mapState({
      mes: 'message'
    })
  },
  created () {
    // this.getUserInfo()
    this.getCourseList()
  },
  methods: {
    async getUserInfo () {
      let res = await getAdminList()
      console.log(res.data)
    },
    async getCourseList () {
      let params = {
        _page: 1, // 分页第1页，每页20条数据
        _limit: 20,
        _sort: 'id', // 按照ID进行降序排序
        _order: 'desc'
      }
      let res = await getCourse(params)
      console.log(res)
    },
    async getCourseCategory () {
      let res = await getCourseCategory()
      console.log(res)
    },
    async addCourseCategory () {
      let params = {
        'pid': -1,
        cName: 'test123'
      }
      let res = await addCourseCategory(params)
      console.log(res)
    },
    async deleteCourseCategory () {
      let params = {
        id: 35
      }
      let res = await deleteCourseCategory(params)
      console.log(res)
    }
  }
}
</script>

<style scoped>

</style>
